import java.util.Scanner;

public class Text {

    //输入一个字符串，求出该字符串包含的字符集合，按照字母输入的顺序输出。
    //数据范围：输入的字符串长度满足，且只包含大小写字母，区分大小写。
    //本题有多组输入
    public static void main1(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String str = sc.nextLine();
            String ret = func(str);
            System.out.println(ret);
        }
    }
    public static String func(String str){
        boolean[] alph = new boolean[60];
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            if(alph[ch-'A'] == false){
                alph[ch-'A'] = true;
                stringBuilder.append(ch);
            }
        }
        return stringBuilder.toString();
    }

    public static int countSegments(String s) {
        if(s == null || s.length() == 0){
            return 0;
        }
        String[] ret = s.split(" ");
        int count = 0;
        for(String x : ret){
            if(x.length() != 0){
                count++;
            }
        }
        return count;
    }
    public static void main2(String[] args) {
        int ret = countSegments("");
        System.out.println(ret);
        System.out.println("".length());
    }


    public static void main(String[] args) {
        MySingleList mySingleList = new MySingleList();
        mySingleList.createList();
        mySingleList.display();
        System.out.println(mySingleList.size());
        mySingleList.addFirst(666);
        mySingleList.addFirst(889);
        mySingleList.display();
        mySingleList.addLast(965);
        mySingleList.addLast(857);
        mySingleList.display();
        mySingleList.addIndex(6,34);
        mySingleList.display();
        mySingleList.addIndex(2,30);
        mySingleList.display();
        System.out.println(mySingleList.contains(965));
        mySingleList.addLast(666);
        mySingleList.display();
        mySingleList.remove(666);
        mySingleList.display();
        mySingleList.addIndex(5,9);
        mySingleList.addLast(9);
        mySingleList.addFirst(9);
        mySingleList.addIndex(9,9);
        mySingleList.display();
        mySingleList.removeAllKey(9);
        mySingleList.display();
        mySingleList.reverseList();
        mySingleList.display();
        System.out.println(mySingleList.midNode());
        System.out.println(mySingleList.lastKNode(7));
        System.out.println(mySingleList.palindrome());
    }
}
